{template 'common/header'}
<script language="javascript">
    function printdiv(printpage)
    {
        var newstr = printpage.innerHTML;
        var oldstr = document.body.innerHTML;
        document.body.innerHTML =newstr;
        window.print();
        document.body.innerHTML=oldstr;
        location.reload();
//        return false;
    }
    $(function(){
        $(".bt").click(function(){
            var div_print=document.getElementById("div_print");
            printdiv(div_print);
        });
        $(".find").click(function(){
            var start_day = $("#start_day").val();
            var end_day = $("#end_day").val();
//            var key_word = $("#key_word").val();
            var region = $("#region").val();
            var type = $("#type").val();
            var member_name = $("#member_name").val();
            var goods_name = $("#goods_name").val();
            var company_id = $("#company_id").val();
            var server_id = $("#server_id").val();
            location.href="{php echo $this->createWebUrl('statistics',array('op' => 'index'))}&start_day="+start_day+"&end_day="+end_day+"&region_id="+region+"&type="+type+"&member_name="+member_name+"&goods_name="+goods_name+"&company_id="+company_id+"&server_id="+server_id;
        });
    });
</script>
<ul class="nav nav-tabs">
    <li {if $goods_type == 1}class="active"{/if} ><a href="{php echo $this->createWebUrl('statistics', array('op'=>'index'))}">普通货物数据统计</a></li>
    <li {if $goods_type == 2}class="active" {/if} ><a href="{php echo $this->createWebUrl('statistics', array('op'=>'index','goods_type' => 2))}">快递数据统计</a></li>
</ul>
<div>
    <div class="panel panel-primary">
        <div class="panel-body" >
            <div class="row">
                <div class="col-xs-2">订单时间(开始)</div>
                <div class="col-xs-2">订单时间(结束)</div>
                <div class="col-xs-2">
                    {if $goods_type == 1}到货区域
                    {else}
                    服务社
                    {/if}
                </div>
                <div class="col-xs-2">搜索客户</div>
                <div class="col-xs-2">货物名称</div>
                <div class="col-xs-2">操作</div>
                <div class="col-xs-2">
                    <input type="date" class="form-control" id="start_day" value="{$start_day}" />
                </div>
                <div class="col-xs-2">
                    <input type="date" class="form-control" id="end_day" value="{$end_day}" />
                </div>
                {if $goods_type == 1}
                <div class="col-xs-2">
                    <select class="form-control" id="region">
                        <option value="0">到货区域</option>
                        {loop $all_regions $region}
                        <option value="{$region['id']}" {if $region['id'] == $region_id} selected="selected" {/if}>{$region['name']}</option>
                        {/loop}
                    </select>
                    <!--<input type="text" class="form-control" placeholder="客户名称/助记码/电话" value="{$key_word}" id="key_word" />-->
                </div>
                {else}
                <div class="col-xs-2">
                    <select class="form-control" id="server_id">
                        <option value="0">服务社</option>
                        {loop $servers $server}
                        <option value="{$server['id']}" {if $server_id == $server['id']} selected="selected" {/if}>{$server['name']}</option>
                        {/loop}
                    </select>
                </div>
                {/if}
                <div class="col-xs-2">
                    <input type="text" placeholder="客户" value="{$member_name}" id="member_name" class="form-control" />
                </div>
                {if $goods_type == 1}
                <div class="col-xs-2">
                    <input type="text" placeholder="货物名称" value="{$goods_name}" id="goods_name" class="form-control" />
                </div>
                {else}
                <div class="col-xs-2">
                    <select class="form-control" id="company_id">
                        <option value="0">快递公司</option>
                        {loop $company $c}
                        <option value="{$c['id']}" {if $company_id == $c['id'] } selected="selected" {/if}>{$c['name']}</option>
                        {/loop}
                    </select>
                </div>
                {/if}
                <div class="col-xs-2">
                    <button class="btn btn-primary find">搜索</button>
                    <!--<button class="btn btn-primary">导出</button>-->
                    <input name="print" type="button" value="打印" class="btn btn-primary bt" />
                </div>
            </div>
            <br />
            <!--<div class="row">-->
            <!--<div class="col-xs-3">-->

            <!--</div>-->
            <!--&lt;!&ndash;<div class="col-xs-3">&ndash;&gt;-->
            <!--&lt;!&ndash;<select class="form-control" id="type">&ndash;&gt;-->
            <!--&lt;!&ndash;<option value="0">全部状态</option>&ndash;&gt;-->
            <!--&lt;!&ndash;<option value="1"  {if $type == 1} selected="selected" {/if}>已收款</option>&ndash;&gt;-->
            <!--&lt;!&ndash;<option value="2" {if $type == 2} selected="selected" {/if} >未收款</option>&ndash;&gt;-->
            <!--&lt;!&ndash;</select>&ndash;&gt;-->
            <!--&lt;!&ndash;</div>&ndash;&gt;-->
            <!--</div>-->
            <div id="div_print" style="display: none;">
                <table class="table table-bordered">
                    <tr>
                        <td align="center">区域</td>
                        <td align="center">货物明细</td>
                    </tr>
                    {loop $regions $region}
                    <tr>
                        <td>{$region['name']}</td>
                        <td>
                            <table class="table">
                                <tr>
                                    <!--<th>货物</th>-->
                                    <th>总件数</th>
                                    <th>总代付款</th>
                                    <th>总已收代付款</th>
                                    <th>总手续费</th>
                                    <th>总已收手续费</th>
                                    <th>总应收运费</th>
                                    <th>总已收运费</th>
                                    <th>总应收</th>
                                    <th>总实收</th>
                                    <th>总运费核销</th>
                                    <th>总未收运费</th>
                                    <th>总未收代付款</th>
                                </tr>
                                {loop $region['goods'] $goods}
                                <tr>
                                    <td>{$goods['total_num']}</td>
                                    <td>{$goods['gen_pay']}</td>
                                    <td>{$goods['total_had_gen']}</td>
                                    <td>{$goods['total_charge']}</td>
                                    <td>{$goods['total_had_charge']}</td>
                                    <td>{$goods['total_freight']}</td>
                                    <td>{$goods['total_had_freight']}</td>
                                    <td>{$goods['total_need']}</td>
                                    <td>{$goods['total_had_need']}</td>
                                    <td>{$goods['total_add_freight']}</td>
                                    <td>{$goods['total_no_freight']}</td>
                                    <td>{$goods['total_no_gen_pay']}</td>
                                </tr>
                                {/loop}
                            </table>
                        </td>
                    </tr>
                    {/loop}
                    <tr>
                        <td>合计</td>
                        <td>
                            <table class="table">
                                <tr>
                                    <th>总件数</th>
                                    <th>总代付款</th>
                                    <th>总已收代付款</th>
                                    <th>总手续费</th>
                                    <th>总已收手续费</th>
                                    <th>总应收运费</th>
                                    <th>总已收运费</th>
                                    <th>总应收</th>
                                    <th>总实收</th>
                                    <th>总运费核销</th>
                                    <th>总未收运费</th>
                                    <th>总未收代付款</th>
                                </tr>
                                <tr>
                                    <td>{$all_numbers}</td>
                                    <td>{$all_gen_pay}</td>
                                    <td>{$all_had_gen}</td>
                                    <td>{$all_charge}</td>
                                    <td>{$all_had_charge}</td>
                                    <td>{$all_freight}</td>
                                    <td>{$all_had_freight}</td>
                                    <td>{$all_need}</td>
                                    <td>{$all_had_need}</td>
                                    <td>{$all_add_freight}</td>
                                    <td>{$all_no_freight}</td>
                                    <td>{$all_no_gen}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
            <div >
                <table class="table table-bordered">
                    <tr>
                        <td align="center">区域</td>
                        <td align="center">货物明细</td>
                    </tr>
                    {loop $regions $region}
                    <tr>
                        <td>{$region['name']}</td>
                        <td>
                            <table class="table">
                                <tr>
                                    <th>总件数</th>
                                    <th>总代付款</th>
                                    <th>总已收代付款</th>
                                    <th>总手续费</th>
                                    <th>总已收手续费</th>
                                    <th>总应收运费</th>
                                    <th>总已收运费</th>
                                    <th>总应收</th>
                                    <th>总实收</th>
                                    <th>总运费核销</th>
                                    <th>总未收运费</th>
                                    <th>总未收代付款</th>
                                </tr>
                                {loop $region['goods'] $goods}
                                <tr>
                                    <td>{$goods['total_num']}</td>
                                    <td>{$goods['gen_pay']}</td>
                                    <td>{$goods['total_had_gen']}</td>
                                    <td>{$goods['total_charge']}</td>
                                    <td>{$goods['total_had_charge']}</td>
                                    <td>{$goods['total_freight']}</td>
                                    <td>{$goods['total_had_freight']}</td>
                                    <td>{$goods['total_need']}</td>
                                    <td>{$goods['total_had_need']}</td>
                                    <td>{$goods['total_add_freight']}</td>
                                    <td>{$goods['total_no_freight']}</td>
                                    <td>{$goods['total_no_gen_pay']}</td>
                                </tr>
                                {/loop}
                            </table>
                        </td>
                    </tr>
                    {/loop}
                    <tr>
                        <td>合计</td>
                        <td>
                            <table class="table">
                                <tr>
                                    <th>总件数</th>
                                    <th>总代付款</th>
                                    <th>总已收代付款</th>
                                    <th>总手续费</th>
                                    <th>总已收手续费</th>
                                    <th>总应收运费</th>
                                    <th>总已收运费</th>
                                    <th>总应收</th>
                                    <th>总实收</th>
                                    <th>总运费核销</th>
                                    <th>总未收运费</th>
                                    <th>总未收代付款</th>
                                </tr>
                                <tr>
                                    <td>{$all_numbers}</td>
                                    <td>{$all_gen_pay}</td>
                                    <td>{$all_had_gen}</td>
                                    <td>{$all_charge}</td>
                                    <td>{$all_had_charge}</td>
                                    <td>{$all_freight}</td>
                                    <td>{$all_had_freight}</td>
                                    <td>{$all_need}</td>
                                    <td>{$all_had_need}</td>
                                    <td>{$all_add_freight}</td>
                                    <td>{$all_no_freight}</td>
                                    <td>{$all_no_gen}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>



{template 'common/footer'}